import {Injectable} from '@angular/core';
import {_HttpClient} from '@delon/theme';
import {Observable} from 'rxjs/Observable';
import {Banner} from './banner';

@Injectable()
export class BannerService {

    url_banner_list = 'Banner/list/';
    url_banner_add = 'Banner/add';
    url_banner_del = 'Banner/del/';
    url_banner_show = 'Banner/show';

    constructor(private http: _HttpClient) {
    }

    getBannerList(page): Observable<any> {
        return this.http.get(this.url_banner_list + page);
    }

    addBanner(item: Banner): Observable<string> {
        return this.http.post(this.url_banner_add, JSON.stringify(item));
    }

    delBanner(id): Observable<string> {
        return this.http.delete(this.url_banner_del + id);
    }

    getBanner(id): Observable<any> {
        return this.http.get(this.url_banner_show, {id: id});
    }

}
